package com.summer.campussct.controller;


import com.summer.campussct.pojo.Permission;
import com.summer.campussct.pojo.dto.RestResult;
import com.summer.campussct.service.IPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 权限表（菜单表） 前端控制器
 * </p>
 *
 * @author Mr.Chen
 * @since 2024-05-12
 */
@RestController
@Api(tags = "权限控制API")
@RequestMapping("/permission")
public class PermissionController {

    @Resource
    private IPermissionService permissionService;

    @ApiOperation("获取权限列表")
    @GetMapping("list")
    public RestResult getList(){
        return permissionService.getList();
    }

    @ApiOperation("添加")
    @PostMapping("add")
    @com.summer.campussct.annotation.Permission
    public RestResult addPermission(@RequestBody Permission permission){
        return permissionService.addPermission(permission);
    }

    @ApiOperation("编辑权限")
    @PutMapping("modify")
    @com.summer.campussct.annotation.Permission
    public RestResult modifyPermission(@RequestBody Permission permission){
        return permissionService.modifyPermission(permission);
    }

    @ApiOperation("获取权限详情")
    @GetMapping("details/{id}")
    public RestResult getDetails(@PathVariable("id") long id){
        return permissionService.getDetails(id);
    }


    @ApiOperation("删除权限")
    @DeleteMapping("delete/{id}")
    public RestResult deleteDetails(@PathVariable("id") long id){
        return permissionService.deleteDetails(id);
    }






}

